import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Endstart
 * Date: 2021-04-24
 * Time: 2:49
 */
public class TestMain111 {

    public static void test() {
        try {
            List<Integer> list = new ArrayList<>();
            String charCount = "123";
            charCount.length();
            int[][] x;
            x = new int[3][];
            x[0] = new int[2];
            x[1] = new int[4];
            x[2] = new int[6];
        } catch (Exception e) {

        }
    }

    public static int[] countInRows(int[][] matrix, int key) {
        if (matrix == null) {
            return null;
        }
        int[] result = new int[matrix.length];
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix[i].length; j++) {
                if (matrix[i][j] == key) {
                    result[i] = j;
                    break;
                }
            }
        }
        return result;
    }

    public static void zeroGreater(int[] a) {
        if (a == null) {
            return;
        }
        zeroGreaterHelper(a, 0);
    }

    public static void zeroGreaterHelper(int[] a, int index) {
        if (index >= a.length) {
            return;
        }
        if (a[index] > index) {
            a[index] = 0;
        }
        zeroGreaterHelper(a, index + 1);
    }

    public static void extractInfo(String fileName) {
        try (BufferedReader reader = new BufferedReader(new FileReader(fileName))) {
            String line = null;
            while ((line = reader.readLine()) != null) {
                String[] strings = line.split(" ");
                int thirdNumber = Integer.parseInt(strings[2]);
                int fifthNumber = Integer.parseInt(strings[4]);
                String secondWord = strings[6];
                String thirdWord = strings[7];
                System.out.println(thirdNumber * fifthNumber + " " + secondWord + " " + thirdWord);
            }
        } catch (IOException e) {
            System.out.println(e.getMessage());
        }
    }

    public abstract class Book {
        private String title;
        private String author;
    } // end class Book

    public class Novel extends Book {
        private String genre;
    } // end class Novel

    public class NonFictionBook extends Book {
        private String subject;
    } // end class NonFictionBook

    public class GraphicNovel extends Book {
        private String illustrator;
    } // end class GraphicNovel

    public static int nonFictionCount(Book[] bookList, int bookListSize) {
        int count = 0;
        if (bookList == null) {
            return count;
        }

        for (int i = 0; i < bookListSize && i < bookList.length; i++) {
            if (bookList[i] != null && bookList[i] instanceof NonFictionBook) {
                count++;
            }
        }
        return count;
    }


    public class IntLinkedList {
        private IntNode top;

        public IntLinkedList() {
            top = null;
        }

        public void moveToFront(int pos) {
            if (pos <= 0 || top == null) {
                return;
            }

            int length = 0;
            IntNode tmp = top;
            while (tmp != null) {
                length++;
                tmp = tmp.link;
            }
            if (pos >= length) {
                return;
            }

            int index = 1;
            IntNode parentNode = top;
            while (index < pos) {
                index++;
                parentNode = parentNode.link;
            }

            IntNode node = parentNode.link;
            parentNode.link = node.link;
            addToStart(node.data);
        }

        public void addToStart(int data) {
            IntNode newNode = new IntNode(data, top);
            top = newNode;
        }
    } // close IntLinkedList

    public class IntNode {
        private int data;
        private IntNode link;

        public IntNode(int data, IntNode link) {
            this.data = data;
            this.link = link;
        }

        public int getData() {
            return data;
        }

        public void setData(int data) {
            this.data = data;
        }

        public IntNode getLink() {
            return link;
        }

        public void setLink(IntNode link) {
            this.link = link;
        }
    } // close IntNode



}
